{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="#">Tables</a>
            </li>
            <li class="active">用户列表</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <!-- <th class="center">
                                            <label>
                                                <input type="checkbox" class="ace" />
                                                <span class="lbl"></span>
                                            </label>
                                        </th> -->
                                        <th>ID</th>
                                        <th>用户名</th>
                                        <th class="hidden-480">姓名</th>

                                        <th>
                                            <i class="icon-time bigger-110 hidden-480"></i>
                                            所属角色
                                        </th>
                                        <th class="hidden-480">操作</th>

                                    </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="v"}
                                    <tr>
                                        <td>{$v['id']}</td>
                                        <td>{$v['username']}</td>
                                        <td>{$v['name']}</td>
                                        <td>
<<<<<<< HEAD
=======
<<<<<<< HEAD:tp5/application/admin/view/user/index.html
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
                                            {volist name="v['role']" id = "x"}
                                            <?php //var_dump($x); ?>
                                                <span style="color:#999">
                                                    <?php
                                                        //foreach($x as $k =>$c){
                                                            //echo $c;
                                                        //}
                                                    ?>
                                                    {volist name="x" id="c"}
                                                    {$c}
                                                    {/volist}
                                                </span>
<<<<<<< HEAD
=======
=======

                                            {volist name="v['role']" id="x"}
                                                <span style="color:#999">
                                                    {volist name="x" id="a"}
                                                        {$a}
                                                    {/volist}
                                                </span>
                                                &nbsp;
>>>>>>> 6accf0d8d13eabad30f3c6fb808de714beb2cd83:tp5/application/admin/view/user/index.html
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
                                            {/volist}
                                        </td>
                                        
                                        <td>
                                            <a href="{:url('admin/user/edit', ['id' => $v['id']])}">修改</a> | 
                                            <a href="{:url('admin/user/showrole', ['id' => $v['id']])}">分配角色</a> | 
                                            <!-- <a href="">删除</a> -->
                                            <button data-id="{$v['id']}" class="btn btn-xs btn-danger del-btn">拉黑</button>
                                        </td>
                                    </tr>
                                {/volist}
                                </tbody>
                            </table>
<<<<<<< HEAD
=======

>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>
{/block}


{block name="myjs"}
{js href="/static/admin/assets/js/toastr.min.js"}
<script>
    $(function () {
        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            console.log('我要拉黑: ' + ac_id + '的角色');

            if (confirm('你确定要 [ 拉 黑 ] 吗?')) {
                var obj = $(this).parents('tr');
                // console.log(obj);
                delAjax(ac_id, obj);
            }
        });

        // 设置弹框参数
        toastr.options = {
            closeButton: true,// 是否显示关闭按钮
            progressBar: true,// 实现显示计时条
            timeOut: "3000",  // 自动关闭时间
            positionClass: "toast-top-right" // 提示位置
            // positionClass: "toast-top-full-width" // 提示位置
            // toast-top-full-width 顶端，宽度铺满整个屏幕
            // toast-top-right  顶端右边
        };
    });

    // 执行ajax删除
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/User/'+ id ,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }


</script>

{/block}




